// DFS 前序遍历 递归
var maxDepth3 = function(root) {
    if (!root) return 0
    let res = 0
    const preorder = (node, currLevel) => {
        if (!node) return
        res = Math.max(res, currLevel)
        preorder(node.left, currLevel + 1)
        preorder(node.right, currLevel + 1)
    }

    preorder(root, 1)
    return res
}

// DFS 后序遍历 递归
var maxDepth = function(root) {
    if (!root) return 0

    const leftMaxDepth = maxDepth(root.left)
    const rightMaxDepth = maxDepth(root.right)

    return Math.max(leftMaxDepth, rightMaxDepth) + 1
}